import 'package:equatable/equatable.dart';
import 'package:backend.purchases/domain/entities/yookassa_api/payments/yookassa_api_pending_payment.dart';
import 'package:backend.purchases/infrastructure/dtos/yookassa_api/payments/pending_payment/yookassa_api_pending_payment_confirmation_info_dto.dart';

const kYookassaApiPendingPaymentRedirectConfirmationInfoReturnUrlKey = 'return_url';
const kYookassaApiPendingPaymentRedirectConfirmationInfoConfirmationUrlKey = 'confirmation_url';

const kYookassaApiPendingPaymentRedirectConfirmationInfoTypeValue = 'redirect';

class YookassaApiPendingPaymentRedirectConfirmationInfoDto extends Equatable
    implements YookassaApiPendingPaymentConfirmationInfoDto {
  const YookassaApiPendingPaymentRedirectConfirmationInfoDto._internal({
    required this.returnUrl,
    required this.confirmationUrl,
  });

  final String returnUrl;
  final String confirmationUrl;

  @override
  String get type => kYookassaApiPendingPaymentRedirectConfirmationInfoTypeValue;

  @override
  List<Object?> get props {
    return [
      returnUrl,
      confirmationUrl,
    ];
  }

  factory YookassaApiPendingPaymentRedirectConfirmationInfoDto.fromJson(Map<String, dynamic> json) {
    return YookassaApiPendingPaymentRedirectConfirmationInfoDto._internal(
      returnUrl: json[kYookassaApiPendingPaymentRedirectConfirmationInfoReturnUrlKey],
      confirmationUrl: json[kYookassaApiPendingPaymentRedirectConfirmationInfoConfirmationUrlKey],
    );
  }

  @override
  YookassaApiPendingPaymentRedirectConfirmationInfo toEntity() {
    return YookassaApiPendingPaymentRedirectConfirmationInfo(
      returnUrl: returnUrl,
      confirmationUrl: confirmationUrl,
    );
  }
}
